//
// A Simple Game Engine
//
// Copyright 2009 CG & CAD Institute, Tsinghua University.
// All rights reserved.
//

#ifndef __ENGINE__GAME_ENGINE_APPEARED__
#define __ENGINE__GAME_ENGINE_APPEARED__

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>
#include <vector>
#include "sprite.h"
#include "timer.h"

namespace engine
{

/**
 * TODO:
 */
class GameEngine
{
// public type forward-declarations & typedefs & defs
public:

// public constructors & destructor
public:
    /**
     * TODO:
     */
    virtual ~GameEngine(void);

// public member functions
public:
    bool Initialize(int width, int height, int bpp, std::string title, int frame);
    void Main();
    void AddSprite(Sprite* sprite);
    void DrawSprite();
    bool UpdateSurface();
    void UpdateSprite();
    void CleanSprite();
    Sprite* IsPointInSprite(int x, int y);
    bool CheckSpriteCollision(Sprite* testSprite);
    int GetWidth();
    int GetHeight();
    void SetSleep(bool sleep);
    bool GetSleep();

// public static member functions
public:
    static GameEngine* GetInstance();

// protected type forward-declarations & typedefs & defs
protected:

// protected member functions
protected:

// protected static member functions
protected:

// private type forward-declarations & typedefs & defs
private:

// private member functions
private:

// private static member functions
private:
    static GameEngine* _gameEngine;

// private data members
private:
    GameEngine(void);
    std::string _title;
    int _width, _height;
    int _bpp;
    int _frame;
    SDL_Surface* _screen;
    std::vector<Sprite*> _sprites;
    SDL_Event _event;
    bool _sleep;

// protected constructors & destructor
protected:

// private constructors & destructor
private:
    // Disable the evil constructor and assignment operator.
    GameEngine(const GameEngine&);
    GameEngine& operator=(const GameEngine&);
};

} // namespace engine

#endif // __ENGINE__GAME_ENGINE_APPEARED__
